package pe.gob.foncodes.ssa.bs.seguridad.domain;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import pe.gob.foncodes.ssa.bs.common.util.Constante;

/**
 *
 * @author aespinoza
 */
@Entity
@Table(name = "ZONAL", catalog = "", schema = "GEN")
@NamedQueries({
    @NamedQuery(name = "Zonal.findAll", query = "SELECT z FROM Zonal z ORDER BY z.txtZonal"),
    @NamedQuery(name = "Zonal.findByCodZonal", query = "SELECT z FROM Zonal z WHERE z.codZonal = ?1"),
    @NamedQuery(name = "Zonal.findByTxtZonal", query = "SELECT z FROM Zonal z WHERE z.txtZonal LIKE ?1 ORDER BY z.codZonal"),
    @NamedQuery(name = "Zonal.findByCodUnidad", query = "SELECT z FROM Zonal z WHERE z.codUnidad = :codUnidad"),
    @NamedQuery(name = "Zonal.findByTipZonal", query = "SELECT z FROM Zonal z WHERE z.tipZonal = :tipZonal"),
    @NamedQuery(name = "Zonal.findByNidUsuarioNidModuloActivos", query = "SELECT DISTINCT z"
                                                                        + " FROM UsuarioPerfil u"
                                                                        + " INNER JOIN u.nidPerfil p, Zonal z"
                                                                        + " WHERE u.nidUsuario.id = ?1"
                                                                        + " AND p.nidModulo.id = ?2"
                                                                        + " AND u.codZonal = z.codZonal"
                                                                        + " AND u.flgActivo = '"+ Constante.ESTADO_ACTIVO +"'"
                                                                        + " AND p.flgActivo = '"+ Constante.ESTADO_ACTIVO +"'"
                                                                        + " AND u.flgCaduca = '"+ Constante.PERFILUSUARIO_NO_CADUCADA  +"'")
})
public class Zonal implements Serializable {
    private static final long serialVersionUID = 1L;
    private String codZonal;
    private String txtZonal;
    private String tipDocumentoIdentidad;
    private String txtDireccion;
    private String txtDocumentoIdentidad;
    private String txtTelefono;
    private String txtFax;
    private String txtNombreJefe;
    private String txtApellidoJefe;
    private String txtModem;
    private Long nidJefeZonal;
    private String txtCargoJefe;
    private String flgTransmision;
    private String codUnidad;
    private String tipZonal;
    private ZonalActiva zonalActiva;
    
    public Zonal() {
    }
    
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 2)
    @Column(name = "COD_ZONAL", nullable = false, length = 2)
    public String getCodZonal() {
        return codZonal;
    }

    public void setCodZonal(String codZonal) {
        this.codZonal = codZonal;
    }

    @Column(name = "TXT_ZONAL", length = 40)
    public String getTxtZonal() {
        return txtZonal;
    }

    public void setTxtZonal(String txtZonal) {
        this.txtZonal = txtZonal;
    }

    @Column(name = "TIP_DOCUMENTO_IDENTIDAD", length = 1)
    public String getTipDocumentoIdentidad() {
        return tipDocumentoIdentidad;
    }

    public void setTipDocumentoIdentidad(String tipDocumentoIdentidad) {
        this.tipDocumentoIdentidad = tipDocumentoIdentidad;
    }

    @Column(name = "TXT_DIRECCION", length = 60)
    public String getTxtDireccion() {
        return txtDireccion;
    }

    public void setTxtDireccion(String txtDireccion) {
        this.txtDireccion = txtDireccion;
    }

    @Column(name = "TXT_DOCUMENTO_IDENTIDAD", length = 20)
    public String getTxtDocumentoIdentidad() {
        return txtDocumentoIdentidad;
    }

    public void setTxtDocumentoIdentidad(String txtDocumentoIdentidad) {
        this.txtDocumentoIdentidad = txtDocumentoIdentidad;
    }

    @Column(name = "TXT_TELEFONO", length = 40)
    public String getTxtTelefono() {
        return txtTelefono;
    }

    public void setTxtTelefono(String txtTelefono) {
        this.txtTelefono = txtTelefono;
    }

    @Column(name = "TXT_FAX", length = 20)
    public String getTxtFax() {
        return txtFax;
    }

    public void setTxtFax(String txtFax) {
        this.txtFax = txtFax;
    }

    @Column(name = "TXT_NOMBRE_JEFE", length = 80)
    public String getTxtNombreJefe() {
        return txtNombreJefe;
    }

    public void setTxtNombreJefe(String txtNombreJefe) {
        this.txtNombreJefe = txtNombreJefe;
    }

    @Column(name = "TXT_APELLIDO_JEFE", length = 80)
    public String getTxtApellidoJefe() {
        return txtApellidoJefe;
    }

    public void setTxtApellidoJefe(String txtApellidoJefe) {
        this.txtApellidoJefe = txtApellidoJefe;
    }

    @Column(name = "TXT_MODEM", length = 20)
    public String getTxtModem() {
        return txtModem;
    }

    public void setTxtModem(String txtModem) {
        this.txtModem = txtModem;
    }

    @Column(name = "NID_JEFE_ZONAL")
    public Long getNidJefeZonal() {
        return nidJefeZonal;
    }

    public void setNidJefeZonal(Long nidJefeZonal) {
        this.nidJefeZonal = nidJefeZonal;
    }

    @Column(name = "TXT_CARGO_JEFE", length = 40)
    public String getTxtCargoJefe() {
        return txtCargoJefe;
    }

    public void setTxtCargoJefe(String txtCargoJefe) {
        this.txtCargoJefe = txtCargoJefe;
    }

    @Column(name = "FLG_TRANSMISION")
    public String getFlgTransmision() {
        return flgTransmision;
    }

    public void setFlgTransmision(String flgTransmision) {
        this.flgTransmision = flgTransmision;
    }

    @Column(name = "COD_UNIDAD", length = 10)
    public String getCodUnidad() {
        return codUnidad;
    }

    public void setCodUnidad(String codUnidad) {
        this.codUnidad = codUnidad;
    }

    @Column(name = "TIP_ZONAL", length = 2)
    public String getTipZonal() {
        return tipZonal;
    }

    public void setTipZonal(String tipZonal) {
        this.tipZonal = tipZonal;
    }

    @OneToOne(cascade = CascadeType.DETACH, mappedBy = "zonal")
    public ZonalActiva getZonalActiva() {
        return zonalActiva;
    }

    public void setZonalActiva(ZonalActiva zonalActiva) {
        this.zonalActiva = zonalActiva;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (codZonal != null ? codZonal.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Zonal)) {
            return false;
        }
        Zonal other = (Zonal) object;
        if ((this.codZonal == null && other.codZonal != null) || (this.codZonal != null && !this.codZonal.equals(other.codZonal))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "pe.gob.foncodes.ssa.bs.seguridad.domain.Zonal[ codZonal=" + codZonal + " ]";
    }
}
